<?php

$app->get('/:language/picture/random/', 'getRandomPicture');

function getRandomPicture($language) {
	$sqlQuery = createPictureSelect($language)." WHERE correctAnswers_$language IS NOT NULL
		AND correctAnswers_$language != '' ORDER BY rand() DESC LIMIT 1";
	echo json_encode(doGetSinglePicture($sqlQuery));
}

function doGetSinglePicture($sqlQuery) {
	$sql = createQuery($sqlQuery);
	$result = mysqli_fetch_object($sql);
	return $result;
}

?>
